<!-- $Id: goods_search.htm 16790 2009-11-10 08:56:15Z wangleisvn $ -->
<script type="text/javascript" src="../plugins/autocomplete/jquery.autocomplete.js"></script>
<script type="text/javascript">	
	jQuery(function() {		
		//category
		jQuery("#cat_name").autocomplete({		
			url: '../plugins/autocomplete/search.php?type=cat',
			
			sortFunction: function(a, b, filter) {			
				var f = filter.toLowerCase();
				var fl = f.length;
				var a1 = a.value.toLowerCase().substring(0, fl) == f ? '0' : '1';
				var a1 = a1 + String(a.data[0]).toLowerCase();
				var b1 = b.value.toLowerCase().substring(0, fl) == f ? '0' : '1';
				var b1 = b1 + String(b.data[0]).toLowerCase();
				if (a1 > b1) {
					return 1;
				}
				if (a1 < b1) {
					return -1;
				}
				return 0;
			},
			showResult: function(value, data) {
				return '<span style="color:red">' + value + '</span>';
			},
			onItemSelect: function(item) {						
				jQuery("#cat_id").val(item.data);
			},
			onNoMatch:function(){
				if(jQuery("#cat_name").val()!=''){
					jQuery("#cat_id").val('111111');
				}else{
					jQuery("#cat_id").val('');
				}
				
				
			},
			maxItemsToShow: 50
		});
		
		//suppliers
		jQuery("#suppliers_name").autocomplete({		
			url: '../plugins/autocomplete/search.php?type=suppliers',
			
			sortFunction: function(a, b, filter) {			
				var f = filter.toLowerCase();
				var fl = f.length;
				var a1 = a.value.toLowerCase().substring(0, fl) == f ? '0' : '1';
				var a1 = a1 + String(a.data[0]).toLowerCase();
				var b1 = b.value.toLowerCase().substring(0, fl) == f ? '0' : '1';
				var b1 = b1 + String(b.data[0]).toLowerCase();
				if (a1 > b1) {
					return 1;
				}
				if (a1 < b1) {
					return -1;
				}
				return 0;
			},
			showResult: function(value, data) {				
				return '<span style="color:red">' + value + '</span>';
			},
			onItemSelect: function(item) {						
				jQuery("#suppliers_id").val(item.data);
			},
			onNoMatch:function(){
				if(jQuery("#suppliers_name").val()!=''){
					jQuery("#suppliers_id").val('-1');
				}else{
					jQuery("#suppliers_id").val('');
				}
				
				
			},
			maxItemsToShow: 50
		});
	
	
	
	});

</script>
<link rel="stylesheet" type="text/css" href="../plugins/autocomplete/jquery.autocomplete.css">	
<div class="form-div">
  <fieldset class="theme_fieldset">
		<h2>注意：</h2>
		<li style="display:none"><?php echo $this->_var['next_sku']; ?></li>
		<li>预修改未经审核的产品不可编辑</li>
		<li>正式产品可通过选项“转到预修改”，重新将产品提交操作人员修正</li>
  </fieldset>

  <form action="javascript:searchGoods()" name="searchForm">
    <img src="images/icon_search.gif" width="26" height="22" border="0" alt="SEARCH" />
    <?php if ($_GET['act'] != "trash"): ?>
    <!-- 分类 -->
    <input name="cat_name" id="cat_name"  value="所有分类">
    <input id="cat_id" value="" type="hidden">
    <!-- 品牌 -->
    <select name="brand_id"><option value="0"><?php echo $this->_var['lang']['goods_brand']; ?></option><?php echo $this->html_options(array('options'=>$this->_var['brand_list'])); ?></select>
    <!-- 推荐 -->
    <select name="intro_type"><option value="0"><?php echo $this->_var['lang']['intro_type']; ?></option><?php echo $this->html_options(array('options'=>$this->_var['intro_list'],'selected'=>$_GET['intro_type'])); ?></select>
     <?php if ($this->_var['suppliers_exists'] == 1): ?>    
      <!-- 供货商 -->
     <input name="suppliers_name" id="suppliers_name"  value="所有供应商">
     <input id="suppliers_id" value="" type="hidden">
      <?php endif; ?>
      <!-- 上架 -->
      <select name="is_on_sale"><option value=''><?php echo $this->_var['lang']['intro_type']; ?></option><option value="1"><?php echo $this->_var['lang']['on_sale']; ?></option><option value="0"><?php echo $this->_var['lang']['not_on_sale']; ?></option></select>
    <?php endif; ?>
    <!-- 关键字 -->
    <?php echo $this->_var['lang']['keyword']; ?> <input type="text" name="keyword" size="15" />
    <input type="submit" value="<?php echo $this->_var['lang']['button_search']; ?>" class="button" />
  </form>
</div>


<script language="JavaScript">
    function searchGoods()
    {

        <?php if ($_GET['act'] != "trash"): ?>
        listTable.filter['cat_id'] = document.forms['searchForm'].elements['cat_id'].value;
        listTable.filter['brand_id'] = document.forms['searchForm'].elements['brand_id'].value;
        listTable.filter['intro_type'] = document.forms['searchForm'].elements['intro_type'].value;
          <?php if ($this->_var['suppliers_exists'] == 1): ?>		  
          listTable.filter['suppliers_id'] = document.forms['searchForm'].elements['suppliers_id'].value;
          <?php endif; ?>
        listTable.filter['is_on_sale'] = document.forms['searchForm'].elements['is_on_sale'].value;
        <?php endif; ?>

        listTable.filter['keyword'] = Utils.trim(document.forms['searchForm'].elements['keyword'].value);
        listTable.filter['page'] = 1;

        listTable.loadList();
    }
</script>
